package com.zyg.dao;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.zyg.pojo.*;
import com.zyg.pojo.Class;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface ClassMapper extends BaseMapper<Class> {
    // 添加一个新的方法来获取包含年级信息的班级列表
    @Select("SELECT class_id,class_name,grade_id FROM sys_class ${ew.customSqlSegment}")
    @Results({
            @Result(property = "classId", column = "class_id"),
            @Result(property = "className", column = "class_name"),
            @Result(property = "gradeId", column = "grade_id"),
            @Result(property = "grade", column = "grade_id", javaType = Grade.class,
                    one = @One(select = "com.zyg.dao.GradeMapper.selectById"))
    })
    List<Class> selectList(IPage<Class> page, @Param(Constants.WRAPPER) Wrapper<Class> queryWrapper);

}
